package com.zxk.service.impl;

import com.sun.jna.platform.win32.WinDef;
import com.zxk.app.ContextHolder;
import com.zxk.constant.PicConstants;
import com.zxk.service.AbstractInstanceTask;
import com.zxk.service.AbstractMyTask;
import com.zxk.util.FuzzyPicUtil;
import com.zxk.util.ThreadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 副本任务作为队员
 *
 * @author: 舟小亢
 * @date: 2024-11-17 9:41
 */
public class InstanceTaskAsMemberImpl extends AbstractInstanceTask {

    private static Logger LOG = LoggerFactory.getLogger(InstanceTaskAsMemberImpl.class);

    public InstanceTaskAsMemberImpl(WinDef.HWND hwnd_0, WinDef.HWND hwnd_1, WinDef.HWND hwnd_2) {
        super(hwnd_0, hwnd_1, hwnd_2);
    }

    @Override
    public String getTaskName() throws Exception {
        return "副本任务队员";
    }

    @Override
    public boolean goHome() throws Exception {
        return true;
    }

    @Override
    public boolean execute() throws Exception {
        return true;
    }

    @Override
    public boolean checkTask() throws Exception {
        LOG.info("【副本任务队员】检查开始");
        // 等待队长执行结束
        while (!ContextHolder.getInstanceTaskDone().get()) {
            LOG.info("【副本任务队员】未完成，等待执行完成");
            ThreadUtil.sleep(10000);
        }
        LOG.info("【副本任务队员】已完成");
        // 队员退出队伍
        afterFinishTaskAsMember();
        LOG.info("【副本任务队员】退出队伍成功");
        return true;
    }
}
